//
//  ViewController.m
//  Masonry撑起父视图
//
//  Created by chenleping on 2018/5/31.
//  Copyright © 2018年 IAPTest. All rights reserved.
//

#import "ViewController.h"

#import <Masonry.h>
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    UIView * superView = [[UIView alloc] init];
    [self.view addSubview:superView];
    
    UILabel * subView = [[UILabel alloc] init];
    [superView addSubview:subView];
    
    superView.backgroundColor = [UIColor greenColor];
    subView.backgroundColor = [UIColor yellowColor];
    
    [superView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.view.mas_left).offset(100);
        make.top.equalTo(self.view.mas_top).offset(100);
        make.right.equalTo(self.view.mas_right).offset(-100);
    }];
    [subView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(superView.mas_left).offset(10);
        make.top.equalTo(superView.mas_top).offset(10);
        make.right.equalTo(superView.mas_right).offset(-10);
        make.bottom.equalTo(superView.mas_bottom).offset(-10);
    }];
    
    subView.numberOfLines = 0;
    subView.text = @"kkjsdaf;a;f;asdkpwfwaiefkdsafsdak'fad'fkldslfskl;adkf;lsdvmnvnb离开家金坷垃 几节课阿斯蒂芬就物品";
    
//    return;
    /**********label上文字两端对齐***********/
    NSMutableAttributedString * attributedString1 = [[NSMutableAttributedString alloc] initWithString:subView.text];
    NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStyle alloc] init];
    //设置label每行文字之间的行间距
//    paragraphStyle1.lineSpacing=8;
    //设置文字两端对齐
    paragraphStyle1.alignment=NSTextAlignmentJustified;
    NSDictionary * dic =@{
                          //这两个一定要加哦。否则就没效果啦
                          NSParagraphStyleAttributeName:paragraphStyle1,
                          NSUnderlineStyleAttributeName:[NSNumber numberWithInteger:NSUnderlineStyleNone],
                          };
    
    [attributedString1 setAttributes:dic range:NSMakeRange(0, attributedString1.length)];
    [subView setAttributedText:attributedString1];
    
}



@end
